package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.UpdateStatusRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TCkPickingwavegoods;
import com.ruoyi.system.service.ITCkPickingwavegoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库任务查询Controller
 * 
 * @author ruoyi
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/system/chuku/pickingwavegoods")
public class TCkPickingwavegoodsController extends BaseController
{
    @Autowired
    private ITCkPickingwavegoodsService tCkPickingwavegoodsService;

    /**
     * 查询出库任务查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCkPickingwavegoods tCkPickingwavegoods)
    {
        startPage();
        String[] addTimes = tCkPickingwavegoods.getWareDates();
        if (addTimes != null && addTimes.length > 1) {
            tCkPickingwavegoods.setStartTime(addTimes[0]);
            tCkPickingwavegoods.setEndsTime(addTimes[1]);
        }
        List<TCkPickingwavegoods> list = tCkPickingwavegoodsService.selectTCkPickingwavegoodsList(tCkPickingwavegoods);
        return getDataTable(list);
    }

    /**
     * 导出出库任务查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:export')")
    @Log(title = "出库任务查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCkPickingwavegoods tCkPickingwavegoods)
    {
        List<TCkPickingwavegoods> list = tCkPickingwavegoodsService.selectTCkPickingwavegoodsList(tCkPickingwavegoods);
        ExcelUtil<TCkPickingwavegoods> util = new ExcelUtil<TCkPickingwavegoods>(TCkPickingwavegoods.class);
        util.exportExcel(response, list, "出库任务查询数据");
    }

    /**
     * 获取出库任务查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:query')")
    @GetMapping(value = "/{PICKINGID}")
    public AjaxResult getInfo(@PathVariable("PICKINGID") String PICKINGID)
    {
        return success(tCkPickingwavegoodsService.selectTCkPickingwavegoodsByPICKINGID(PICKINGID));
    }

    /**
     * 新增出库任务查询
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:add')")
    @Log(title = "出库任务查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCkPickingwavegoods tCkPickingwavegoods)
    {
        return toAjax(tCkPickingwavegoodsService.insertTCkPickingwavegoods(tCkPickingwavegoods));
    }

    /**
     * 修改出库任务查询
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:edit')")
    @Log(title = "出库任务查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCkPickingwavegoods tCkPickingwavegoods)
    {
        return toAjax(tCkPickingwavegoodsService.updateTCkPickingwavegoods(tCkPickingwavegoods));
    }

    /**
     * 删除出库任务查询
     */
    @PreAuthorize("@ss.hasPermi('system:pickingwavegoods:remove')")
    @Log(title = "出库任务查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{PICKINGIDs}")
    public AjaxResult remove(@PathVariable String[] PICKINGIDs)
    {
        return toAjax(tCkPickingwavegoodsService.deleteTCkPickingwavegoodsByPICKINGIDs(PICKINGIDs));
    }

    @PostMapping("/updateCkRwSts")
    public AjaxResult updateCkSts(@RequestBody UpdateStatusRequest request) {
        return toAjax(tCkPickingwavegoodsService.updateCkSts(request));
    }
}
